BLACK = ...
BLUE = ...
RED = ...
GREEN = ...
CYAN = ...
MAGENTA = ...
YELLOW = ...
WHITE = ...

FAST = ...
SLOW = ...

MADCTL_MY = ...
MADCTL_MX = ...
MADCTL_MV = ...
MADCTL_ML = ...
MADCTL_MH = ...

RGB = ...
BGR = ...

WRAP = ...
WRAP_H = ...
WRAP_V = ...


def color565(r:int, g:int, b:int) -> int:
	'''
	Pack a color into 2-bytes rgb565 format
	'''
	...

class ST7789():
	def __init__(self):
		...

	def map_bitarray_to_rgb565(self, bitarray, buffer, width, color=WHITE, bg_color=BLACK):
		'''
		Convert a bitarray to the rgb565 color buffer that is suitable for blitting.
		Bit 1 in bitarray is a pixel with color and 0 - with bg_color.
		'''
		...

	def inversion_mode(self, bool:bool):
		'''
		Sets the display color inversion mode if True, clears the display color inversion mode if False.
		'''
		...

	def madctl(self, value=None):
		'''
		Returns the current value of the MADCTL register.\n
		Optionally sets the MADCTL register if a value is passed to the method.

		- value:
			- MADCTL_MY: Page Address Order
			- MADCTL_MX: Column Address Order
			- MADCTL_MV: Page/Column Order
			- MADCTL_ML: Line Address Order
			- MADCTL_MH: Display Data Latch Order
			- RGB: RGB color order
			- BGR: BGR color order
		'''
		...

	def on(self):
		'''
		Turn on the backlight pin if one was defined during init.
		'''
		...

	def off(self):
		'''
		Turn off the backlight pin if one was defined during init.
		'''
		...
	
	def pixel(self, x:int, y:int, color:int):
		'''
		Set the specified pixel to the given color.
		'''
		...
	
	def line(self, x0:int, y0:int, x1:int, y1:int, color:int):
		'''
		Draws a single line with the provided color from (x0, y0) to (x1, y1).
		'''
		...
	
	def hline(self, x:int, y:int, length:int, color:int):
		'''
		Draws a single horizontal line with the provided color and length in pixels.\n
		Along with vline, this is a fast version with reduced number of SPI calls.
		'''
		...

	def vline(self, x:int, y:int, length:int, color:int):
		'''
		Draws a single horizontal line with the provided color and length in pixels.
		'''
		...
	
	def rect(self, x:int, y:int, width:int, height:int, color:int):
		'''
		Draws a rectangle from (x, y) with corresponding dimensions
		'''
		...
	
	def fill_rect(self, x:int, y:int, width:int, height:int, color:int):
		'''
		Fill a rectangle starting from (x, y) coordinates
		'''
		...
	
	def circle(self, x:int, y:int, r:int, color:int):
		'''
		Draws a circle with radius r centered at the (x, y) coordinates in the given color.
		'''
		...
	
	def fill_circle(self, x:int, y:int, r:int, color:int):
		'''
		Draws a filled circle with radius r centered at the (x, y) coordinates in the given color.
		'''
		...
	
	def blit_buffer(self, buffer:bytearray, x:int, y:int, width:int, height:int):
		'''
		Copy bytes() or bytearray() content to the screen internal memory.\n
		Note: every color requires 2 bytes in the array
		'''
		...
	
	def text(self, font, s:str, x:int, y:int, fg=WHITE, bg=BLACK):
		'''
		Write text to the display using the specified bitmap font with the coordinates as the upper-left corner of the text.\n
		The foreground and background colors of the text can be set by the optional arguments fg and bg.\n
		Otherwise the foreground color defaults to WHITE and the background color defaults to BLACK.\n
		See the README.md in the fonts/bitmap directory for example fonts.
		'''
		...

	def write(self, bitmap_font, s:str, x:int, y:int, fg=WHITE, bg=BLACK, background_tuple=None, fill_flag=None):
		'''
		Write text to the display using the specified proportional or Monospace bitmap font module with the coordinates as the upper-left corner of the text.\n
		The foreground and background colors of the text can be set by the optional arguments fg and bg.\n
		Otherwise the foreground color defaults to WHITE and the background color defaults to BLACK.\n
		Transparency can be emulated by providing a background_tuple containing (bitmap_buffer, width, height).\n
		This is the same format used by the jpg_decode method. See examples/T-DISPLAY/clock/clock.py for an example.\n

		See the README.md in the truetype/fonts directory for example fonts.\n
		Returns the width of the string as printed in pixels. Accepts UTF8 encoded strings.
		'''
		...
	
	def write_len(self, bitap_font, s:str):
		'''
		Returns the width of the string in pixels if printed in the specified font.
		'''
		...
	
	def draw(self, vector_font, s:str, x:int, y:int, fg=WHITE, scale=1.0):
		'''
		Draw text to the display using the specified hershey vector font with the coordinates as the lower-left corner of the text.\n
		The foreground color of the text can be set by the optional argument fg\n
		Otherwise the foreground color defaults to WHITE.\n
		The size of the text can be scaled by specifying a scale value.\n
		The scale value must be larger then 0 and can be a floating point or an integer value.\n
		The scale value defaults to 1.0.\n
		See the README.md in the vector/fonts directory for example fonts and the utils directory for a font conversion program.
		'''
		...
	
	def draw_len(self, vector_font, s:str, scale=1.0):
		'''
		Returns the width of the string in pixels if drawn with the specified font.
		'''
		...
	
	def jpg(self, jpg_filename:str, x:int, y:int, method=FAST):
		'''
		Draw JPG file on the display at the given x and y coordinates as the upper left corner of the image.\n
		There memory required to decode and display a JPG can be considerable as a full screen 320x240 JPG would require at least 3100 bytes for the working area + 320 * 240 * 2 bytes of ram to buffer the image.\n
		Jpg images that would require a buffer larger than available memory can be drawn by passing SLOW for method.\n
		The SLOW method will draw the image a piece at a time using the Minimum Coded Unit (MCU, typically a multiple of 8x8) of the image.

		- method:
			- FAST
			- SLOW
		'''
		...

	def jpg_decode(self, jpg_filename:str, x=None, y=None, width=None, height=None) -> bytearray:
		'''
		Decode a jpg file and return it or a portion of it as a tuple composed of (buffer, width, height).\n
		The buffer is a color565 blit_buffer compatible byte array.\n
		The buffer will require width * height * 2 bytes of memory.

		If the optional x, y, width and height parameters are given the buffer will only contain the specified area of the image.\n
		See examples/T-DISPLAY/clock/clock.py examples/T-DISPLAY/toasters_jpg/toasters_jpg.py for examples.
		'''
		...
	
	def polygon_center(self, polygon) -> tuple:
		'''
		Return the center of the polygon as an (x, y) tuple.\n
		The polygon should consist of a list of (x, y) tuples forming a closed convex polygon.
		'''
		...
	
	def fill_polygon(self, polygon, x:int, y:int, color:int, angle=None, center_x=None, center_y=None):
		'''
		Draw a filled polygon at the x, y coordinates in the color given.\n
		The polygon may be rotated angle radians about the center_x and center_y point.\n
		The polygon should consist of a list of (x, y) tuples forming a closed convex polygon.\n
		See the TWATCH-2020 watch.py demo for an example.
		'''
		...
	
	def polygon(self, polygon, x:int, y:int, color:int, angle=None, center_x=None, center_y=None):
		'''
		Draw a polygon at the x, y coordinates in the color given.\n
		The polygon may be rotated angle radians about the center_x and center_y point.\n
		The polygon should consist of a list of (x, y) tuples forming a closed convex polygon.\n
		See the T-Display roids.py for an example.
		'''
		...
	
	def bounding(self, status:bool, as_rect:bool) -> tuple:
		'''
		Bounding turns on and off tracking the area of the display that has been written to.\n
		Initially tracking is disabled, pass a True value to enable tracking and False to disable.\n
		Passing a True or False parameter will reset the current bounding rectangle to (display_width, display_height, 0, 0).\n
		
		- Returns:
			- a four integer tuple containing (min_x, min_y, max_x, max_y) indicating the area of the display that has been written to since the last clearing.
			- If as_rect parameter is True, the returned tuple will contain (min_x, min_y, width, height) values.

		See the TWATCH-2020 watch.py demo for an example.
		'''
		...
	
	def bitmap(self, bitmap, x:int, y:int, index=None):
		'''
		Draw bitmap using the specified x, y coordinates as the upper-left corner of the of the bitmap.\n
		The optional index parameter provides a method to select from multiple bitmaps contained a bitmap module.\n
		The index is used to calculate the offset to the beginning of the desired bitmap using the modules HEIGHT, WIDTH and BPP values.
		'''
		...

	def width(self):
		'''
		Returns the current logical width of the display. (ie a 135x240 display rotated 90 degrees is 240 pixels wide)
		'''
		...
	
	def height(self):
		'''
		Returns the current logical height of the display. (ie a 135x240 display rotated 90 degrees is 135 pixels high)
		'''
		...

	def rotation(self, r:int):
		'''
		Set the rotates the logical display in a counter-clockwise direction.
		- r: 
			- 0-Portrait (0 degrees)
			- 1-Landscape (90 degrees)
			- 2-Inverse Portrait (180 degrees)
			- 3-Inverse Landscape (270 degrees)
		'''
		...
	
	def offset(x_start:int, y_start:int):
		'''
		The memory in the ST7789 controller is configured for a 240x320 display.\n
		When using a smaller display like a 240x240 or 135x240 an offset needs to added to the x and y parameters so that the pixels are written to the memory area that corresponds to the visible display.\n
		The offsets may need to be adjusted when rotating the display.
		'''